﻿<!--#include file="../lib/base.asp"-->
<!--#include file="../theme.asp"-->
<%
sdcms.checkuserlogin
dim act:act=lcase(sdcms.fget("act",0))
select case act
	case "checkdb":checkdb()
	case else
		sdcms.show theme_user_user,""
end select

sub checkdb()
	dim t0,t1
	t0=sdcms.enhtml(sdcms.fpost("emailedit",0))
	t1=sdcms.enhtml(sdcms.fpost("nickname",0))
	if not(sdcms.checkpost) then
		sdcms.ajaxjson "禁止外部提交数据",0
		exit sub
	end if
	if sdcms.strlen(t0)=0 then
		sdcms.ajaxjson "邮箱不能为空",0
		exit sub
	end if
	if not(sdcms.checkstr(t0,"email")) then
		sdcms.ajaxjson "邮箱格式不正确",0
		exit sub
	end if
	dim userdata:userdata=sdcms.userinfo
	if t0<>userdata(3) then
		if sdcms.db.dbcount("sd_user","email='"&t0&"'")>0 then
			sdcms.ajaxjson "邮箱已存在，请换个试试",0
			exit sub
		end if
		sdcms.db.dbupdate "sd_user","id="&userdata(0)&"",array(array("email",t0,0,1),array("nickname",t1,10,1))
	else
		sdcms.db.dbupdate "sd_user","id="&userdata(0)&"",array(array("nickname",t1,10,1))
	end if
	sdcms.resetuserinfo "u.id="&userdata(0)&""
	sdcms.ajaxjson "修改成功",1
end sub
sdcms.db.dbclose
%>